"""
    读取https://www.csdn.net/网址右侧导航栏
"""

import lxml.etree as le
import urllib.request as ur

# 请求url
request = ur.Request('https://www.csdn.net/')
response = ur.urlopen(request).read()
html_x = le.HTML(response)
# 通过筛选得到所需的div对象
div_x_s = html_x.xpath('//div[@class="list-group"]/span/em/text()')
# 去除提取到的对象中“导航”两字，若不存在“导航”二字，则跳过
try:
    div_x_s.remove('导航')
except ValueError:
    pass
print('导航：')
for div_x in div_x_s:
    print('  ' + div_x.strip())